<!doctype html>
<html lang="en">
{% load static %}
<head>
    <meta charset="UTF-8">
    <title>恢复确认</title>
    <script src="{% static "js/jquery.js" %}"></script>
    <script src="{% static "js/sweetalert.js" %}"></script>
    <link rel="stylesheet" href="{% static "css/sweetalert.css" %}"/>
    <link rel="stylesheet" href="{% static "css/bootstrap.min.css" %}"/>
    <script type="text/javascript">
        $(function () {
            swal({
                title: '确认恢复？',
                text: '此次恢复的记录数为【' + '{{ count }}' + '】条',
                type: 'warning',
                showCancelButton: true,
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                closeOnConfirm: false,
                closeOnCancel: false
            }, function (isConfirm) {
                if (isConfirm) {
                    $.ajax({
                        type: 'POST',
                        url: '/chart/restore/',
                        dataType: 'json',
                        data: {
                            rid: '{{ rid }}',
                            tbl: '{{ tbl }}',
                            csrfmiddlewaretoken: '{{ csrf_token }}'
                        },
                        success: function () {
                            window.location.href = '/admin/pms/pydbhandle/'
                        },
                        error: function (err) {
                        }
                    })
                    swal({
                        title: "恢复成功！",
                        timer: 1000,
                        type: "success"
                    }, function () {
                        window.location.href = '/admin/pms/pydbhandle/'
                    })
                } else {
                    swal({
                        title: "取消恢复！",
                        timer: 1000,
                        type: "error"
                    }, function () {
                        window.location.href = '/admin/pms/pydbhandle/'
                    })
                }
            });
        });
    </script>
</head>
<body>
</body>
</html>